package com.com.designpatterns.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by User on 17/09/2014.
 */
public interface Graphic {
    public void print();
}

class CompositeGraphic implements Graphic{

    // Collection of child graphic
    private List<Graphic> childGraphics = new ArrayList<Graphic>();

    @Override
    public void print() {
        for(Graphic graphic : childGraphics){
            graphic.print();
        }
    }

    public void add(Graphic graphic){
        childGraphics.add(graphic);
    }

    public void remove(Graphic graphic){
        childGraphics.remove(graphic);
    }
}

class Ellipse implements Graphic{
    @Override
    public void print() {
        System.out.println("Ellipse." );
    }
}

